void CDead6800::AddCycles(int n)		//add cycles to cycle counter
{
Cycle += n;
}

__inline void CDead6800::Indexed()
{
u16 *Dest,t;
u8 Byte;

Byte = Read(PC++);
//message("indexed addressing...byte = $%02X...\n",Byte);
switch((Byte >> 5) & 3)
	{
	default:
	case 0:	Dest = &X;	break;
//	case 1:	Dest = &Y;	break;
//	case 2:	Dest = &U;	break;
	case 3:	Dest = &S;	break;
	}
if((Byte & 0x80) == 0)
	{
	if(Byte & 0x10)		//negative
		EA = *Dest - (0x10 - (Byte & 0xF));
	else						//positive
		EA = *Dest + (Byte & 0xF);
	Cycle++;
	return;
	}
switch(Byte & 0xF)
	{
	default:message("indexed addressing...bad mode index ($%02X)...\n",Byte);break;
	case 0x0:
		EA = *Dest;
		*Dest += 1;
		Cycle += 2;
		break;
	case 0x1:
		EA = *Dest;
		*Dest += 2;
		Cycle += 3;
		break;
	case 0x2:
		*Dest -= 1;
		EA = *Dest;
		Cycle += 2;
		break;
	case 0x3:
		*Dest -= 2;
		EA = *Dest;
		Cycle += 2;
		break;
	case 0x4:
		EA = *Dest;
		break;
	case 0x5:
		EA = (u16)(*Dest + (s16)(s8)B);
		Cycle++;
		break;
	case 0x6:
		EA = (u16)(*Dest + (s16)(s8)A);
		//message("idx $%02X, EA = $%04X\n",Byte,EA);
		Cycle++;
		break;
	case 0x8:
		//EA = (u16)(*Dest + (s16)(s8)Read(PC++));		//correct?
		t = Read(PC++);
		if(t & 0x80)
			t |= 0xFF00;
		EA = (u16)(*Dest + t);
		Cycle++;
		break;
	case 0x9:
		EA = (u16)(*Dest + ReadWord(PC));
		PC += 2;
		Cycle += 4;
		break;
	case 0xB:
		EA = (u16)(*Dest + D);
		Cycle += 4;
		break;
	case 0xC:
		EA = Read(PC++);
		EA += PC;
		EA &= 0xFFFF;
		Cycle += 1;
	case 0xD:
		EA = ReadWord(PC);
		PC += 2;
		EA += PC;
		EA &= 0xFFFF;
		Cycle += 5;
	case 0xF:
		EA = ReadWord(PC);
		PC += 2;
		Cycle += 5;
		break;
	}
if(Byte & 0x10)
	{
	EA = ReadWord(EA);
	Cycle += 3;
	}
}

__inline void CDead6800::PushS(u8 data)
{
Write(S,data);
S--;
}

__inline void CDead6800::PushS16(u16 data)
{
PushS((u8)data);
PushS((u8)(data >> 8));	
}

__inline u8 CDead6800::PullS()
{
S++;
return(Read(S));
}

__inline u16 CDead6800::PullS16()
{
u16 ret;

ret = PullS() << 8;
ret |= PullS();
return(ret);
}
